/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package serveurtp2;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import serveurtp2.exceptions.*;

/**
 *
 * @author scriptoff
 */
public class CoucheMetier extends UnicastRemoteObject implements CoucheMetierRemoteResources {

    public CoucheMetier() throws RemoteException {
    }
    
    public double calculAnnuit(double montantPret,double taux,int nombreAnnee) throws RemoteException, ErreurMontantPretException, ErreurTauxException, ErreurNombreAnneeException {
        if(montantPret <=0)
            throw new ErreurMontantPretException();
        if(taux <= 0)
            throw new ErreurTauxException();
        if(nombreAnnee <= 0)
            throw new ErreurNombreAnneeException();
        return ((montantPret*(taux/100))+montantPret/nombreAnnee);

    }
    public double calculNombreAn(double montantPret,double taux,double montantAnnuit) throws RemoteException, ErreurMontantPretException, ErreurTauxException, ErreurMontantAnnuitException {
        if(montantPret <=0)
            throw new ErreurMontantPretException();
        if(taux <= 0)
            throw new ErreurTauxException();
        if(montantAnnuit <=0)
            throw new ErreurMontantAnnuitException();
        return (montantAnnuit/(montantPret*((taux/100))));
    }
    
}
